package com.lzy.cloud.order.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lzy.cloud.order.dtos.OrderInfoCarSaleDto;
import com.lzy.cloud.order.entity.OrderInfoCarSale;
import com.lzy.cloud.order.mapper.OrderInfoCarSaleMapperExt;
import com.lzy.cloud.order.service.OrderInfoCarSaleService;
import com.lzy.framework.core.orm.db.Pager;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @description:房车销售订单子表
 * @author: liyun
 * @create: 2018-07-05 16:14
 */
@Service
public class OrderInfoCarSaleServiceImpl implements OrderInfoCarSaleService {
    @Autowired
    private OrderInfoCarSaleMapperExt orderInfoCarSaleMapperExt;

    @Override
    public OrderInfoCarSaleDto queryByOrderId(String orderId) {
        return orderInfoCarSaleMapperExt.queryByOrderId(orderId);
    }

    @Override
    public boolean create(OrderInfoCarSaleDto orderInfoCarSaleDto) {
        return orderInfoCarSaleMapperExt.insertSelective(DozerUtils.map(orderInfoCarSaleDto, OrderInfoCarSale.class)) > 0;
    }

    @Override
    public boolean update(OrderInfoCarSaleDto orderInfoCarSaleDto) {
        return orderInfoCarSaleMapperExt.updateByPrimaryKeySelective(DozerUtils.map(orderInfoCarSaleDto, OrderInfoCarSale.class)) > 0;
    }

    @Override
    public PageInfo<OrderInfoCarSaleDto> selectList(Pager pager, OrderInfoCarSaleDto dto) {
        if (pager != null)
            PageHelper.startPage(pager.getPageNum(), pager.getPageSize());
        return new PageInfo<>(orderInfoCarSaleMapperExt.selectList(dto));
    }

}
